﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>启动应用程序</title>
    <script type="text/javascript" src="~/Common/js/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="~/Common/js/vue.min.js"></script>
    <style>
        * {
            margin: 0;
            box-sizing: border-box;
        }
    </style>
</head>
<body style="background-color:#e4dfd6">
    <div id="app" style="height:100vh;overflow:hidden">
        <button v-on:click="handleStartApp()">{{ button_name }}</button>
    </div>
</body>
<script type="text/javascript">
    var vm = new Vue({
        el: "#app",
        data: {
            button_name: "启动"
        },
        computed: {
        },
        methods: {
            handleStartApp: function () {
                var that = this;
                if (that.button_name == "启动中...") return;
                that.button_name = "启动中...";
                $["post"]("api/database/init", null, function (res) {
                    console.log(res);
                    if (res.status == 10000) {
                        that.button_name = "启动成功";
                        document.location.href = "/";
                    }else {
                        alert(res.message);
                    }
                    that.button_name = "启动";
                });
            }
        },
        created() {
        }
    });









    //var query_data = {};
    //jQuery.ajaxSettings.data = {
    //    token: "qwertuyiadsfghjk"
    //}
    //function request(method) {
    //    var require_json;
    //    try {
    //        eval("require_json = " + $("#require").val());
    //        var url = $("#url").val();
    //        $("#result").html("接口" + url + "请求已发送");
    //        $[method]("/api/" + url, require_json, function (res) {
    //            console.log(res);
    //            $("#result").html(JSON.stringify(res, null, 4));
    //        });
    //    } catch (err) {
    //        $("#result").html(err.message);
    //    }
    //}
    //$("#get_btn").click(function () {
    //    request("get");
    //});
    //$("#post_btn").click(function () {
    //    request("post");
    //});
    //$("#update_database_btn").click(function () {
    //    $("#url").val("database/init");
    //    request("post");
    //});
    //$("#add_btn").click(function () {
    //    $("#url").val("database/init");
    //    request("post");
    //});
    //$("#delete_btn").click(function () {
    //    $("#url").val("database/init");
    //    request("post");
    //});

    //$("#require").val("{\n\t\n\t\"exemption\": 1 // 1免检，0有权限检测\n}");
</script>
</html>
